package com.ruoyi.ai.controller;

import com.ruoyi.ai.assistant.RuoYiAgent;
import com.ruoyi.ai.bean.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import reactor.core.publisher.Flux;

public class RuoYiController {
    private final RuoYiAgent ruoYiAgent;

    public RuoYiController(RuoYiAgent ruoYiAgent) {
        this.ruoYiAgent = ruoYiAgent;
    }

    @Operation(summary = "对话")
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        return ruoYiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
    }
}
